package com.zyd.shiro.business.enums;

/**
 * @Classname RespCode 采购方式
 * @Description TODO
 * @Date 2020/6/14 8:14
 * @Created by King
 */
public enum PurMethod {
    STOCK(1, "采购"),
    LEASE(2, "租赁"),
    OTHER(3, "其他");

    private Integer code;
    private String msg;

    PurMethod(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static String getMsgByCode(int code) {
        for (PurMethod purMethod : PurMethod.values()) {
            if (purMethod.getCode() == code) {
                return purMethod.getMsg();
            }
        }
        return "未知";
    }

    public static int getCodeByMsg(String msg) {
        for (PurMethod purMethod : PurMethod.values()) {
            if (purMethod.getMsg().equals(msg)) {
                return purMethod.getCode();
            }
        }
        return 0;
    }
}
